/**
 * 用户管理列表数据提供 及渲染
 */
import { Divider, Radio, Table } from 'antd';
import React, { useState } from 'react';
import ButtonUser from './ButtonUser'

const App = (props) => {
  const [selectionType, setSelectionType] = useState('checkbox');
  const [userId,setUserId] =useState('');
  const rowSelection = {
    onChange: (selectedRowKeys, selectedRows) => {
      for (let i = 0; i < selectedRows.length; i++) {
        setUserId(selectedRows);
      }
    },
    getCheckboxProps: (record) => ({
      disabled: record.name === 'Disabled User',
      name: record.name,
    }),
  };
  return (
    <div>
      <div className={'userButDiv'}>
         <ButtonUser getUserId ={userId}/>
      </div>
      <div className={'radioDiv'}>
        <Radio.Group
          onChange={({ target: { value } }) => {
            setSelectionType(value);
          }}
          value={selectionType}
        >
          <Radio value="checkbox">Checkbox</Radio>
          <Radio value="radio">radio</Radio>
        </Radio.Group>
      </div>
      <Divider />
      <Table
        rowSelection={{
          type: selectionType,
          ...rowSelection,
        }}
        scroll={{
          y: 350
        }}
        columns={props.columns}
        dataSource={props.dataSource}
      />
    </div>
  );
};
export default App;